package com.xzl.org.learning_situation_analysis.service.Impl;

import com.xzl.org.learning_situation_analysis.dao.QuestionScoreMapper;
import com.xzl.org.learning_situation_analysis.entity.QuestionScore;
import com.xzl.org.learning_situation_analysis.service.QuestionScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author 夏智力
 * @FileName QuestionScoreServiceImpl
 * @date 2022/4/14 15:00
 * @Software: IntelliJ IDEA
 */
@Service
public class QuestionScoreServiceImpl implements QuestionScoreService {

    @Autowired
    private QuestionScoreMapper questionScoreMapper;

    @Override
    public List<QuestionScore> selectByPaperIdAndStudentId(int paperId, int studentId) {
        return questionScoreMapper.selectByPaperIdAndStudentId(paperId, studentId);
    }

    @Override
    public HashMap<Integer, Float> selectPaperTotalScoreByPaperId(int paperId) {
        return questionScoreMapper.selectPaperTotalScoreByPaperId(paperId);
    }

    @Override
    public int insertQuestionScore(QuestionScore questionScore) {
        questionScore.setReleaseTime(new Date(System.currentTimeMillis()));
        return questionScoreMapper.insertQuestionScore(questionScore);
    }

    @Override
    public int updateScore(int id, float score) {
        return questionScoreMapper.updateScore(id, score);
    }
}
